@extends('Admin.Layouts.index')

@section('active5')
    active
@endsection

@section('title_name')
    商品列表
@endsection

@section('container')
    <div class="container">
        <div class="mws-panel grid_8">
            <div class="mws-panel-header">
                <span><i class="icon-table"></i> 商品列表 </span>
            </div>
            <div class="mws-panel-body no-padding">
                <div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">

                    <form action="/admin/goods/index" method="get">
                        <div id="DataTables_Table_1_length" class="dataTables_length">
                            <label>
                                显示
                                <select size="1" name="num" aria-controls="DataTables_Table_1">
                                    <option value="10" onclick="location.href='/admin/goods?num=10{{$keywords}}{{$hotUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($num == 10) selected @endif>10</option>
                                    <option value="25" onclick="location.href='/admin/goods?num=25{{$keywords}}{{$hotUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($num == 25) selected @endif>25</option>
                                    <option value="50" onclick="location.href='/admin/goods?num=50{{$keywords}}{{$hotUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($num == 50) selected @endif>50</option>
                                    <option value="100" onclick="location.href='/admin/goods?num=100{{$keywords}}{{$hotUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($num == 100) selected @endif>100</option>
                                </select>
                                条数据
                            </label>
                        </div>
                        <div id="DataTables_Table_1_length" class="dataTables_length">
                            <label>
                                是否热销
                                <select size="1" name="hot" aria-controls="DataTables_Table_1">
                                    <option value="" onclick="location.href='/admin/goods?{{$keywords}}{{$numUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($hot == '') selected @endif>不限</option>
                                    <option value="1" onclick="location.href='/admin/goods?hot=1{{$keywords}}{{$numUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($hot == 1) selected @endif>是</option>
                                    <option value="0" onclick="location.href='/admin/goods?hot=0{{$keywords}}{{$numUrl}}{{$bestUrl}}{{$newsUrl}}'" @if($hot === 0) selected @endif>否</option>
                                </select>
                            </label>
                        </div>
                        <div id="DataTables_Table_1_length" class="dataTables_length">
                            <label>
                                是否精品
                                <select size="1" name="best" aria-controls="DataTables_Table_1">
                                    <option value="" onclick="location.href='/admin/goods?{{$keywords}}{{$numUrl}}{{$hotUrl}}{{$newsUrl}}'" @if($best == '') selected @endif>不限</option>
                                    <option value="1" onclick="location.href='/admin/goods?best=1{{$keywords}}{{$numUrl}}{{$hotUrl}}{{$newsUrl}}'" @if($best == 1) selected @endif>是</option>
                                    <option value="0" onclick="location.href='/admin/goods?best=0{{$keywords}}{{$numUrl}}{{$hotUrl}}{{$newsUrl}}'" @if($best === 0) selected     @endif>否</option>
                                </select>
                            </label>
                        </div>
                        <div id="DataTables_Table_1_length" class="dataTables_length">
                            <label>
                                是否新品
                                <select size="1" name="news" aria-controls="DataTables_Table_1">
                                    <option value="" onclick="location.href='/admin/goods?{{$keywords}}{{$numUrl}}{{$hotUrl}}{{$bestUrl}}'" @if($news == '') selected @endif>不限</option>
                                    <option value="1" onclick="location.href='/admin/goods?news=1{{$keywords}}{{$numUrl}}{{$hotUrl}}{{$bestUrl}}'" @if($news == 1) selected @endif>是</option>
                                    <option value="0" onclick="location.href='/admin/goods?news=0{{$keywords}}{{$numUrl}}{{$hotUrl}}{{$bestUrl}}'" @if($news === 0) selected     @endif>否</option>
                                </select>
                            </label>
                        </div>
                        <div class="dataTables_filter" id="DataTables_Table_1_filter">
                            <label>关键字: <input aria-controls="DataTables_Table_1" name="keywords" type="text" value="{{$request->keywords}}">
                                <button type="submit" class="btn btn-primary">搜索</button>
                            </label>
                        </div>
                    </form>


                    <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1"
                           aria-describedby="DataTables_Table_1_info">
                        <thead>
                        <tr role="row">
                            <th class="_asc" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 169px;" aria-sort="ascending"
                                aria-label="Rendering engine: activate to sort column descending">ID
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 229px;"
                                aria-label="Browser: activate to sort column ascending">商品名称
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 213px;"
                                aria-label="Platform(s): activate to sort column ascending">stock
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">在销
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">精品
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">热门
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">新品
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">分类
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">品牌
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">销售量
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">访问量
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">评论量
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">颜色
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 145px;"
                                aria-label="Engine version: activate to sort column ascending">尺码
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 106px;"
                                aria-label="CSS grade: activate to sort column ascending">创建时间
                            </th>
                            <th class="" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 106px;"
                                aria-label="CSS grade: activate to sort column ascending">更新时间
                            </th>
                            <th class="" tabindex="0" aria-controls="DataTables_Table_1"
                                rowspan="1" colspan="1" style="width: 106px;"
                                aria-label="CSS grade: activate to sort column ascending">操作
                            </th>

                        </tr>
                        </thead>

                        <tbody role="alert" aria-live="polite" aria-relevant="all" style="text-align: center">

                        @if(count($goods) > 0)
                            @foreach($goods as $k=>$v)
                                @if($k %2 == 1)
                                    <tr class="odd">
                                @else
                                    <tr class="even">
                                @endif
                                        <td class="  _1">{{$v['id']}}</td>
                                        <td class=" ">{{$v['goods_name']}}</td>
                                        <td class=" ">{{$v['goods_stock']}}</td>
                                        <td class=" ">{{show($v['is_sale'])}}</td>
                                        <td class=" ">{{show($v['is_best'])}}</td>
                                        <td class=" ">{{show($v['is_hot'])}}</td>
                                        <td class=" ">{{show($v['is_new'])}}</td>
                                        <td class=" ">{{$v['cate_id']}}</td>
                                        <td class=" ">{{$v['brand_id']}}</td>
                                        <td class=" ">{{$v['sale_num']}}</td>
                                        <td class=" ">{{$v['visit_num']}}</td>
                                        <td class=" ">{{$v['appraise_num']}}</td>
                                        <td class=" ">{{$v['goods_color']}}</td>
                                        <td class=" ">{{$v['goods_size']}}</td>
                                        <td class=" ">{{$v['created_at']}}</td>
                                        <td class=" ">{{$v['updated_at']}}</td>
                                        <td class=" ">
                                            <a href="/admin/goods/edit/{{$v['id']}}" alt="修改用户" class="btn btn-small"><i class="icon-pencil"></i></a>
                                            <a href="/admin/goods/delete/{{$v['id']}}"  alt="回收用户" class="btn btn-small"><i class="icon-trash"></i></a>
                                        </td>
                                    </tr>
                            @endforeach
                        @else
                            <tr><td colspan="5">暂无数据</td></tr>
                        @endif
                        </tbody>
                    </table>
                    <div class="dataTables_info" id="DataTables_Table_1_info">显示第 {{($goods->currentPage()-1) * $goods->perPage() +1}} 到第 {{($goods->currentPage()-1) * $goods->perPage() + $goods->count()}} 条数据 共 {{$goods->total()}} 条数据</div>
                    <div class="dataTables_paginate paging_full_numbers" id="page">
                        {!! $goods->appends($request->all())->render() !!}
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection